/**
 * @Author: lianghuan
 * @Description: RecoveryMiddleware
 * @emoji - ( ゜- ゜)つロ 乾杯~
 * @email lianghuanA@outlook.com
 * @Date: 2021-10-12 17:09
 * @Version: 1.0.0
 */

package middleware

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"go-gin/response"
)

func RecoveryMiddleware() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		defer func() {
			if err := recover(); err != nil {
				response.Fail(ctx, nil, fmt.Sprint(err))
			}
		}()
		ctx.Next()
	}
}
